/*******************************************************************************
 * Copyright 2011-2012 Dik Grapendaal
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *   http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 ******************************************************************************/
package sh.grapendaal.tsuushin.module.uno;

import sh.grapendaal.tsuushin.annotation.Callback;
import sh.grapendaal.tsuushin.annotation.Module;
import sh.grapendaal.tsuushin.message.IncomingMessage;
import sh.grapendaal.tsuushin.message.MessageType;
import sh.grapendaal.tsuushin.message.incoming.IncomingPrivateMessage;
import sh.grapendaal.tsuushin.message.outgoing.OutgoingPrivateMessage;
import sh.grapendaal.tsuushin.tracking.Context;

@Module(author = "Dik Grapendaal", version = "0.0.1")
public class Uno {

	@Callback(type = MessageType.CHANNEL_MESSAGE)
	public void onPrivateMessage(Context context, IncomingMessage message) {
		IncomingPrivateMessage incoming = (IncomingPrivateMessage) message;

		if (incoming.getContent().startsWith("jo")) {
			OutgoingPrivateMessage outgoing = new OutgoingPrivateMessage();
			outgoing.setDestination(incoming.getChannel());
			outgoing.setMessage(incoming.getUser().getNickname() + " has joined the game.");
			context.getBot().send(outgoing);
		} else if (incoming.getContent().startsWith("le")) {
			OutgoingPrivateMessage outgoing = new OutgoingPrivateMessage();
			outgoing.setDestination(incoming.getChannel());
			outgoing.setMessage("kbie, " + incoming.getUser().getNickname() + ".");
			context.getBot().send(outgoing);
		}
	}
}
